@extends('layouts.admin')
@section('css')
    <link href="{{asset('vendors/dataTables/datatables.min.css')}}" rel="stylesheet">
@endsection
@section('content')
    <div class="row wrapper border-bottom white-bg page-heading">
        <div class="col-lg-10">
            <h2>奖品</h2>
            <ol class="breadcrumb">
                <li>
                    <a href="{{url('admin/dash')}}">{!!trans('admin/breadcrumb.home')!!}</a>
                </li>
                <li class="active">
                    <strong>奖品统计</strong>
                </li>
            </ol>
        </div>
    </div>
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-lg-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>奖品统计</h5>
                        <div class="ibox-tools">
                            <button id="add-prizes-btn" data-toggle="modal" data-target="#add-prizes-modal"
                                    class="btn btn-sm btn-info"><i class="fa fa-plus"></i> 添加奖品
                            </button>
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        @include('flash::message')
                        <div class="table-responsive">
                            <table class="table table-striped table-bordered table-hover dataTablesAjax">
                                <thead>
                                <tr>
                                    <th>奖品</th>
                                    <th>总数</th>
                                    <th>剩余</th>
                                    <th>状态</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Modal -->
    <div class="modal fade add-prizes-modal" id="add-prizes-modal" tabindex="-1" role="dialog"
         aria-labelledby="add-prizes-modal">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                                aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">增加奖品</h4>
                </div>
                <div class="modal-body">
                    <div class="alert alert-warning" role="alert">如果无cdKey，请在无cdKey直接填写个数；<br>如果有，请上传Excel格式的文件，第一行为表头，第二行以下为cdKey！<br><b>注意：当无号和有号都有值时，都将会导入数据库</b>
                    </div>
                    <form class="form-horizontal add-prizes-form">
                        {{csrf_field()}}
                        <div class="form-group">
                            <label class="col-sm-2 control-label">奖品名称</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="name" id="prizes-name"
                                       placeholder="奖品名称">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">兑换截止日期</label>
                            <div class="col-sm-10">
                                <input type="datetime" class="form-control" name="deadline" id="prizes-deadline"
                                       placeholder="格式：0000-00-00 00:00">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">兑换链接</label>
                            <div class="col-sm-10">
                                <input type="url" class="form-control" name="url" id="prizes-url"
                                       placeholder="请输入奖品兑换链接">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">奖品价值</label>
                            <div class="col-sm-10">
                                <input type="number" class="form-control" name="value" id="prizes-value"
                                       placeholder="请输入奖品价值（元）">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">无cdKey奖品数量</label>
                            <div class="col-sm-10">
                                <input type="number" class="form-control" name="noNumber" id="prizes-noNumber"
                                       placeholder="请输入无cdKey奖品数量">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">导入奖品文件</label>
                            <div class="col-sm-10">
                                <input type="file" class="form-control" name="file" id="prizes-file">
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default"
                            data-dismiss="modal">{{trans('admin/action.actionButton.close')}}</button>
                    <button type="button" class="btn btn-primary add-prizes-ok-btn">{!! trans('admin/action.actionButton.submit')!!}</button>
                </div>
            </div>
        </div>
    </div>
@endsection
@section('js')
    <script src="{{asset('vendors/dataTables/datatables.min.js')}}"></script>
    <script src="{{asset('vendors/layer/layer.js')}}"></script>
    <script src="{{asset('admin/js/prize/index.js')}}"></script>
    <script type="text/javascript">
        $(document).on('click', '.destroy_item', function () {
            var _item = $(this);
            var title = "{{trans('admin/alert.deleteTitle')}}";
            layer.confirm(title, {
                btn: ['{{trans('admin/action.actionButton.destroy')}}', '{{trans('admin/action.actionButton.no')}}'],
                icon: 5
            }, function (index) {
                _item.children('form').submit();
                layer.close(index);
            });
        });
    </script>
@endsection